---
import GuideHeader from '../../components/GuideHeader.astro';
import MarkdownFile from '../../components/MarkdownFile.astro';
import BaseLayout from '../../layouts/BaseLayout.astro';
import { getAllGuides, GuideFileType } from '../../lib/guide';

export interface Props {
  guide: GuideFileType;
}

export async function getStaticPaths() {
  const guides = await getAllGuides();

  return guides.map((guide) => ({
    params: { guideId: guide.id },
    props: { guide },
  }));
}

const { guideId } = Astro.params;
const { guide } = Astro.props;
const { frontmatter: guideData } = guide;
---

<BaseLayout
  title={guideData.seo.title}
  description={guideData.seo.description}
  permalink={`/guides/${guideId}`}
  canonicalUrl={guideData.canonicalUrl}
>
  <GuideHeader guide={guide} />

  <div class='py-5 sm:py-10 max-w-[700px] mx-auto'>
    <MarkdownFile>
      <guide.Content />
    </MarkdownFile>
  </div>
</BaseLayout>
